<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>合同修改</title>
</head>
<link rel="stylesheet" href="/static/layui/css/layui.css" />
<body>
<form class="layui-form"  action="" lay-filter="edit">
    <input type="hidden" name="id">
    <div class="layui-form-item">
        <label class="layui-form-label">昵称：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="username" id="username"  required  lay-verify="required" placeholder="请输入新昵称" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">性别：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="sex" id="sex"  required  lay-verify="required" placeholder="请输入新性别" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">生日：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="birthday" id="birthday"  required  lay-verify="required" placeholder="请输入新生日" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">科室：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="department_type" id="department_type"  required  lay-verify="required" placeholder="请输入新政治面貌" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">电话：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="phone" id="phone"  required  lay-verify="required" placeholder="请确认电话" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">地址：</label>
        <div class="layui-input-inline layui-col-md4">
            <input type="text" name="address" id="address"  required  lay-verify="required" placeholder="请确认地址" autocomplete="off" class="layui-input">
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
        </div>
    </div>
</form>
</body>
<script src="/static/js/system.js"></script>
<script src="/static/js/jquery-3.3.1.js"></script>
<script src="/static/layui/layui.js"></script>
<script>
    //Demo
    layui.use(['form','layer'], function(){
        var form = layui.form;
        /*$.ajax({
            url:"/UserServlet?action=toAddContr",
            type:"post",
            // data:{},
            dataType:"json",
            success:function (res) {
                console.log(res)
                $.each(res.date,function (i,obj) {
                    console.log(obj);
                    $("#h_id").append('<option value="'+obj.h_id+'" >' + obj.h_estate + obj.h_unitNumber+obj.h_roomNo +'</option>');
                });
                form.render('select'); //刷新select选择框渲染
            }
        });

        $.ajax({
            url:"/UserServlet?action=toAddLess",
            type:"post",
            // data:{},
            dataType:"json",
            success:function (res) {
                console.log(res)
                $.each(res.date,function (i,obj) {
                    console.log(obj);
                    $("#l_id").append('<option value="'+obj.l_id+'">'+ obj.l_name +'</option>')
                });
                form.render('select'); //刷新select选择框渲染
            }
        });
*/
        $.ajax({
            url:'/user/findAlltow',
            type:"post",
            dataType:"json",
            data:{"email":getQueryString("email")},
            success:function (da) {
                console.log(da)
                if (da.code == 200) {
                    /*form.val("edit", da.date);*/
                    form.val("edit", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                        /*"h_id": da.date.h_estate+da.date.h_unitNumber+da.date.h_roomNo // "name": "value"
                        ,"l_id": da.date.l_name,*/
                        "username": da.date.username
                        ,"sex": da.date.sex // "name": "value"
                        ,"birthday": da.date.birthday
                        ,"political_status":da.date.political_status
                        ,"phone": da.date.phone
                        ,"address": da.date.address
                    });
                } else {
                    parent.layer.msg("详情查询失败！");
                }
            }
        });
        //监听提交 15039939677
        form.on('submit(formDemo)', function(data){
            var data1 = form.val("edit");
            $.ajax({
                url:'/hisuser/updatetow',
                type:"post",
                dataType:"json",
                data:data1,
                success:function (da) {
                    console.log(da)
                    if (da.code == 200) {
                        layer.alert("修改成功！", function () {
                            // window.parent.location.reload();//刷新父页面
                            // parent.layer.close(layer.index);//关闭弹出层
                            parent.layer.closeAll();
                        });
                    } else {
                        layer.msg("修改失败！");
                    }
                }
            });
            return false;
        });
    });
</script>
</html>